//
//  BN_UserInfo.m
//  BabyNow
//
//  Created by iMobile on 14-4-2.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "BN_UserInfo.h"

NSString *const kBN_Account = @"account";
NSString *const kBN_SchoId = @"schoId";
NSString *const kBN_HeadUrl = @"headUrl";
NSString *const kBN_Id = @"id";
NSString *const kBN_ClasId = @"clasId";
NSString *const kBN_BirtDate = @"birtDate";
NSString *const kBN_UserName = @"userName";
NSString *const kBN_Password = @"password";
NSString *const kBN_UserType = @"userType";
NSString *const kBN_ClasName = @"clasName";
NSString *const kBN_SchoName = @"schoName";

@implementation BN_UserInfo

// 初始化方法
- (id)initWithAccount:(NSString *)account
               schoId:(NSString *)schoId
              headUrl:(NSString *)headUrl
               userId:(NSString *)userId
               clasId:(NSString *)clasId
            birthData:(NSString *)birthDate
             userName:(NSString *)userName
             password:(NSString *)password
             clasName:(NSString *)clasName
             schoName:(NSString *)schoName
             userType:(NSString *)userType
{
    if (self = [super init]) {
        _account = account;
        _schoId = schoId;
        _headUrl = headUrl;
        _userId = userId;
        _clasId = clasId;
        _birtDate = birthDate;
        _userName = userName;
        _password = password;
        _clasName = clasName;
        _schoName = schoName;
        _userType = userType;
    }
    return self;
}

// 基于Json字典对象初始化BN_UserInfo对象
#warning 需要检测一下空值
- (id)initWithJsonDict:(NSDictionary *)dict{
    if (self = [super initWithJsonDict:dict]) {
        if (self.info) {
            _account = self.info[kBN_Account];
            _schoId = self.info[kBN_SchoId];
            _headUrl = self.info[kBN_HeadUrl];
            _userId = self.info[kBN_Id];
            _clasId = self.info[kBN_ClasId];
            _birtDate = self.info[kBN_BirtDate];
            _userName = self.info[kBN_UserName];
            _password = self.info[kBN_Password];
            _clasName = self.info[kBN_ClasName];
            _schoName = self.info[kBN_SchoName];
            _userType = self.info[kBN_UserType];
        }
    }
    return self;
}


#pragma mark - NSCoding Delegate method

- (id)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super init]) {
        _account = [aDecoder decodeObjectForKey:kBN_Account];
        _schoId = [aDecoder decodeObjectForKey:kBN_SchoId];
        _headUrl = [aDecoder decodeObjectForKey:kBN_HeadUrl];
        _userId = [aDecoder decodeObjectForKey:kBN_Id];
        _birtDate = [aDecoder decodeObjectForKey:kBN_BirtDate];
        _userName = [aDecoder decodeObjectForKey:kBN_UserName];
        _password = [aDecoder decodeObjectForKey:kBN_Password];
        _clasName = [aDecoder decodeObjectForKey:kBN_ClasName];
        _schoName = [aDecoder decodeObjectForKey:kBN_SchoName];
        _userType = [aDecoder decodeObjectForKey:kBN_UserType];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:_account forKey:kBN_Account];
    [aCoder encodeObject:_schoId forKey:kBN_SchoId];
    [aCoder encodeObject:_headUrl forKey:kBN_HeadUrl];
    [aCoder encodeObject:_userId forKey:kBN_Id];
    [aCoder encodeObject:_birtDate forKey:kBN_BirtDate];
    [aCoder encodeObject:_userName forKey:kBN_UserName];
    [aCoder encodeObject:_password forKey:kBN_Password];
    [aCoder encodeObject:_clasName forKey:kBN_ClasName];
    [aCoder encodeObject:_schoName forKey:kBN_SchoName];
    [aCoder encodeObject:_userType forKey:kBN_UserType];
}

@end
